package com.isoft.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.isoft.IService.IGirlService;
import com.isoft.domain.Girl;
import com.isoft.mapper.GirlMapper;

/**
 * 
 * @Author yigeyanse@hotmail.com
 * @Date 2017年9月6日 上午10:11:24
 */
@Service
public class GirlService implements IGirlService {
    @Resource
    private GirlMapper girlMapper;

    @Override
    public Girl findGirlById(Integer id){
        return girlMapper.findGirlById(id);
    }

    @Override
    @Transactional
    public void addGirl(Girl girl) {
        girlMapper.add(girl);
    }

    @Override
    public Page<Girl> findAllGirls(Integer pageNum) {
        /*
         * 第一个参数是第几页；第二个参数是每页显示条数。
         */
        PageHelper.startPage(pageNum,4);
        List<Girl> list = girlMapper.getAllGirls();
        Page<Girl> page = (Page<Girl>) list;
        return page;
    }
}
